﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EditUserCommission.aspx.cs"
    Inherits="LotteryVote.EditUserCommission" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="JS/jquery.js" type="text/javascript"></script>
    <link href="Style/comm.css" rel="stylesheet" type="text/css" />
    <link href="Style/Commission.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function parseCommission() {
            var txtboxs = $("#commTb input");
            var isFirst = true;
            var content = "[";
            $(txtboxs).each(function (i, ele) {
                if (ele.id == "comm") {
                    if (isFirst)
                        isFirst = false;
                    else
                        content += ",";
                    ele = $(ele);
                    var item = "{" + "\"Comm\":" + ele.val() + ",\"CommissionId\":" + <%=CommissionId %> + ",\"CompanyTypeId\":" + ele.attr("comtype") + ",\"GameId\":" + ele.attr("gametype") + "}";
                    content += item;
                }
            });
            content += "]";
            $("#<%=hd_submitValue.ClientID %>").val(content);
        }

        function getQuery(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null)
                return unescape(r[2]);
            return null;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server" onsubmit="return parseCommission()">
    <h3>
        <%=GetGlobalResourceObject("Resource","Commission") %></h3>
    <table id="commTb" cellpadding="0" cellspacing="0">
        <thead>
            <tr>
                <td rowspan="2">
                    GameType
                </td>
                <%foreach (var comType in CompanyTypeList)
                  { %>
                <td>
                    <%=comType.Description %>
                </td>
                <%} %>
            </tr>
            <tr>
                <%for (int i = 0; i < CompanyTypeList.Count; i++)
                  { %>
                <td>
                    Comm
                </td>
                <%--<td>
                Odds
            </td>--%>
                <%} %>
            </tr>
        </thead>
        <%
            foreach (var gameType in GameTypeList)
            {%>
        <tr>
            <td>
                <%=gameType.Description %>
            </td>
            <%foreach (var comType in CompanyTypeList)
              { %>
            <td>
                <input id="comm" gametype='<%=gameType.Value %>' comtype='<%=comType.Value %>' type="text"
                    value='<%=GetCommVal(comType.Value,gameType.Value).Comm %>' />
            </td>
            <%} %>
        </tr>
        <%} %>
    </table>
    <asp:HiddenField ID="hd_submitValue" runat="server" />
    <asp:Button ID="btn_submit" runat="server" Text="<%$Resources:Resource,Submit %>"
        OnClick="btn_submit_Click" />
    <h3>
        <%=GetGlobalResourceObject("Resource","Package") %></h3>
    <table cellpadding="0" cellspacing="0">
        <colgroup>
            <col style="background: #B3B3B3" />
        </colgroup>
        <%foreach (var model in UserCommissionGroup)
          { %>
        <tr>
            <td>
                <%=model.CommGroup.GroupName %>
            </td>
            <td>
                <table id="commTb" cellpadding="0" cellspacing="0">
                    <thead>
                        <tr>
                            <td rowspan="2">
                                GameType
                            </td>
                            <%foreach (var comType in CompanyTypeList)
                              { %>
                            <td colspan="2">
                                <%=comType.Description %>
                            </td>
                            <%} %>
                        </tr>
                        <tr>
                            <%for (int i = 0; i < CompanyTypeList.Count; i++)
                              { %>
                            <td>
                                Comm
                            </td>
                            <td>
                                Odds
                            </td>
                            <%} %>
                        </tr>
                    </thead>
                    <%foreach (var gameType in GameTypeList)
                      {%>
                    <tr>
                        <td>
                            <%=gameType.Description%>
                        </td>
                        <%foreach (var comType in CompanyTypeList)
                          { %>
                        <td>
                            <%=GetComm(model,comType.Value,gameType.Value).Commission%>
                        </td>
                        <td>
                            <%=GetComm(model,comType.Value,gameType.Value).Odds%>
                        </td>
                        <%} %>
                    </tr>
                    <%} %>
                </table>
            </td>
        </tr>
        <%} %>
    </table>
    </form>
</body>
</html>
